#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    menu[0] = new QMenu("File");
    menu[0]->addAction("Edit");
    menu[0]->addAction("View");
    menu[0]->addAction("Tools");

    act[0] = new QAction("New",this);
    act[0]->setShortcut(Qt::CTRL|Qt::Key_A);
    act[0]->setStatusTip("this is a new menu");

    act[1] = new QAction("Open",this);
    act[1]->setCheckable(true);

    menu[1] = new QMenu("Save");
    menu[1]->addAction(act[0]);
    menu[1]->addAction(act[1]);

    menu[2] = new QMenu("Print");
    menu[2]->addAction("Page Setup");
    menu[2]->addMenu(menu[1]);

    this->menubar = new QMenuBar(this);

    menubar->setGeometry(0,0,300,100);

    menubar->addMenu(menu[0]);
    menubar->addMenu(menu[2]);


    connect(menubar,SIGNAL(triggered(QAction*)),this,SLOT(triggerMenu(QAction*)));







}

Widget::~Widget()
{
}

void Widget::triggerMenu(QAction* act){
    QString str = QString("Selected Menu : %1").arg(act->text());
    qDebug(str.toStdString().c_str());
}


